package hu.mapro.gwtui.client.model;

import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.text.shared.AbstractSafeHtmlRenderer;

public class LabelProviderRenderer<T> extends AbstractSafeHtmlRenderer<T> {

	private final LabelProvider<? super T> labelProvider;

	public LabelProviderRenderer(LabelProvider<? super T> labelProvider) {
		this.labelProvider = labelProvider;
	}

	@Override
	public SafeHtml render(T object) {
		SafeHtmlBuilder sb = new SafeHtmlBuilder();
		sb.appendEscaped(labelProvider.getLabel(object));
		return sb.toSafeHtml();
	}

}
